import type { BasicColumn, FormSchema } from '@/components/Table'
import { useRender } from '@/components/Table'
import { DICT_TYPE, getDictOptions } from '@/utils/dict'

export const columns: BasicColumn[] = [

  {
    title: '游戏名称',
    dataIndex: 'name',
    width: 160,
  },
  {
    title: '游戏资源地址',
    dataIndex: 'url',
    width: 160,
  },
  {
    title: '单价金额',
    dataIndex: 'amount',
    width: 160,
  },
  {
    title: '游戏状态',
    dataIndex: 'status',
    width: 160,
    customRender: ({ text }) => {
      return useRender.renderDict(text, DICT_TYPE.COMMON_STATUS)
    },
  },
  {
    title: '游戏时长(分钟)',
    dataIndex: 'time',
    width: 160,
  },
  {
    title: '创建人',
    dataIndex: 'creator',
    width: 160,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
    customRender: ({ text }) => {
      return useRender.renderDate(text)
    },
  },
]

export const gameColumns: BasicColumn[] = [

  {
    title: '游戏名称',
    dataIndex: 'name',
    width: 60,
  },
  {
    title: '游戏资源地址',
    dataIndex: 'url',
    width: 60,
  },
  {
    title: '单价金额',
    dataIndex: 'amount',
    width: 160,
  },

  {
    title: '游戏状态',
    dataIndex: 'status',
    width: 60,
    customRender: ({ text }) => {
      return useRender.renderDict(text, DICT_TYPE.COMMON_STATUS)
    },
  },
  {
    title: '游戏时长(分钟)',
    dataIndex: 'time',
    width: 160,
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    label: '游戏名称',
    field: 'name',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: '游戏状态',
    field: 'status',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.COMMON_STATUS),
    },
    colProps: { span: 8 },
  },
  {
    label: '创建人',
    field: 'creator',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: '创建时间',
    field: 'createTime',
    component: 'RangePicker',
    colProps: { span: 8 },
  },
]

export const createFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input',
  },
  {
    label: '游戏名称',
    field: 'name',
    required: true,
    component: 'Input',
  },
  {
    label: '游戏资源地址',
    field: 'url',
    component: 'Input',
  },
  
  {
    label: '单价金额',
    field: 'amount',
    component: 'Input',
  },
  {
    label: '游戏状态',
    field: 'status',
    required: true,
    component: 'RadioButtonGroup',
    componentProps: {
      options: getDictOptions(DICT_TYPE.COMMON_STATUS),
    },
  },
  {
    label: '游戏时长（分钟）',
    field: 'time',
    required: true,
    component: 'Input',
  },
]

export const updateFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input',
  },
  {
    label: '游戏名称',
    field: 'name',
    required: true,
    component: 'Input',
  },
  {
    label: '游戏资源地址',
    field: 'url',
    component: 'Input',
  },
  {
    label: '单价金额',
    field: 'amount',
    component: 'Input',
  },
  {
    label: '游戏状态',
    field: 'status',
    required: true,
    component: 'RadioButtonGroup',
    componentProps: {
      options: getDictOptions(DICT_TYPE.COMMON_STATUS),
    },
  },
  {
    label: '游戏时长（分钟）',
    field: 'time',
    required: true,
    component: 'Input',
  },
]
